function ajax (type , url , data){
    return new Promise ((resolve , reject) => {
        var str = ''
        for(var key in data){
            str += `${key}=${data[key]}&`
        }
        str = str.slice(0,str.length - 1)

        var xhm = new XMLHttpRequest()
        xhm.open(type , type == 'get' ? url + '?' + str : url)
        xhm.onreadystatechange = () => {
            if(xhm.readyState == 4){
                resolve(JSON.parse(xhm.responseText))
            }
        }
        xhm.setRequestHeader('conment' , 'application/x-www-form-urlencoded')
        xhm.send(type == 'post' ? str : null)
    })
}